#pragma once

#include "commons.hxx"

#define REGISTER_CONDITIONS(site,decision,args) info_syslog("*Register conditions, from: '%s.dll(.so)'...\n",TO_STRING(site));CHECK(OUR_register_conditions(decision,args))
#define ADD_TYPE_CONDITION(business,message,func,args) {METHOD_id_t method_id = {0, NULL};\
info_syslog("+Type condition - %s: %s\n",business,message);\
CHECK(METHOD_find_method(business,message,&method_id));\
if(ITK_ok == ifail)CHECK(METHOD_add_pre_condition(method_id,func,args));}
#define ADD_PROP_CONDITION(business,name,message,func,args) {METHOD_id_t method_id = {0, NULL};\
info_syslog("+Property condition - %s.%s: %s\n",business,name,message);\
CHECK(METHOD_find_prop_method(business,name,message,&method_id));\
if(ITK_ok == ifail)CHECK(METHOD_add_pre_condition(method_id,func,args));}

/// <summary>
/// 业务对象验证
/// </summary>
typedef struct tag_type_condition {
    const char* business;
    const char* message;
    METHOD_function_t func;
    TC_argument_list_t* args;
} OUR_type_condition;

/// <summary>
/// 业务属性验证
/// </summary>
typedef struct tag_prop_condition {
    const char* business;
    const char* name;
    const char* message;
    METHOD_function_t func;
    TC_argument_list_t* args;
} OUR_prop_condition;

/// <summary>
/// 注册验证方法
/// </summary>
/// <param name="decision"></param>
/// <param name="args"></param>
/// <returns>是否注册成功</returns>
int OUR_register_conditions(int* decision, va_list args);
